package lab1;

/**
 * Title: Part2 class for CSIS 235 Lab 1 
 * Description: CS 235 Lab #1 - Part 2
 *  Simple Java program with various arithmetic operations.
 * 
 * @author Anthony Varghese
 * @email anthony.varghese@uwrf.edu
 * @date January 4th 2012
 */

public class Part2 {
	private static java.io.PrintStream out = System.out;

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		print_max_int();
		print_min_int();

		print_max_float();

		print_bad_subtraction();
	}

	/*
	 * print_max_int - this method prints the value of the largest int value in
	 * Java and, in addition, the value that results when a variable set to the
	 * largest int is incremented.
	 */
	private static void print_max_int() {
		out.println(); // empty line
		int value = Integer.MAX_VALUE;
		out.println("Largest int value is:                         " + value);

		value++;
		out.println("Incrementing the largest int value gives us: " + value);
	}

	/*
	 * print_min_int - this method prints the value of the smallest (largest
	 * negative) int value in Java and, in addition, the value that results when
	 * a variable set to the smallest int is decremented.
	 */
	private static void print_min_int() {
		out.println(); // empty line
	}

	/*
	 * print_max_float - this method prints the value of the largest float value
	 * in Java and, in addition, the value that results when a variable set to
	 * the largest float is multiplied by a value larger than 1.
	 */
	private static void print_max_float() {
		out.println(); // empty line
		float value = Float.MAX_VALUE;
		out.println("Largest float value is:                      " + value);

		value *= 1.001f;
		out.println("Increasing the largest float value gives us: " + value);
	}

	/*
	 * print_bad_subtraction - . what is odd about this is that when we subtract
	 * 0.9 from 1 we can do this in our heads - the answer should be 0.1
	 * However, computers using IEEE 64-bit arithmetic will fail to compute the
	 * correct answer 0.1 regardless of the programming language used.
	 */
	private static void print_bad_subtraction() {
		out.println(); // empty line
		double a = 1.0;
		double b = 0.9;
		System.out.println("  a is " + a + " and b is " + b);

		double c = a - b;
		System.out.println("  a - b is " + c);
	}
}